#include "communicate.hpp"
#include "log.hpp"
using namespace std;
int main()
{
    // 创建管道
    Init init;
    Log log;
    log.chMethon(MoreFile);
    // 打开管道
    int fd = open("./myfifo", O_RDONLY);
    if (fd == -1)
    {
        log(Fatal, "%s", strerror(errno));
        return -1;
    }

    // 开始通信
    while (1)
    {
        char buffer[1024] = {0};
        ssize_t ret = read(fd, buffer, sizeof(buffer));
        if (ret > 0)
        {
            log(Debug, "%s %s", "sever get inf:", buffer);
        }
        else if (ret == 0)
        {
            log(Debug, "%s", "client quit, sever quit too");
            break;
        }
        else
            break;
    }

    // 结束通信
    close(fd);
}